import reqeust from "@/utils/request";

export interface User {
  _id: string;
  username: string;
  photo: string;
}

export interface CommentList {
  _id: string;
  content: string;
  user: User;
  isLike: boolean;
}

export interface Data {
  commentList: CommentList[];
  count: number;
}

export interface RootObject {
  data: Data;
  code: number;
  message: string;
}


export interface Data1 {
  _id: string;
  content: string;
  user: string;
  proposition: string;
  likeCount: number;
  isLike: boolean;
}

interface discuss {
  content: string,
  proposition: string,
}



export default {
  // 获取 评论的分页列表
  requestGetComment: (page: number, pagesize: number, proposition: number) => {
    return reqeust.get<any, Data>(
      `proposition/getComment?page=${page}&pagesize=${pagesize}&proposition=${proposition}`
    )
  },
  //获取 评论 登录
  requestGetCommentLogin: (page: number, pagesize: number, proposition: number) => {
    return reqeust.get<any, Data>(
      `proposition/getComment?page=${page}&pagesize=${pagesize}&proposition=${proposition}`
    )
  },
  //发表评论请求
  requestCreteComment: (data: discuss) => {
    return reqeust.post<any, Data1>("proposition/comment", data);
  },
  //删除评论
  requestDeleteComment: (deleteId: string) => {
    return reqeust.delete<any, any>(`proposition/deleteComment/${deleteId}`);
  },
  //点赞
  requestFabulous: (comment: string) => {
    return reqeust.get<any, any>(`proposition/like?comment=${comment}`);
  },

}